#!/bin/sh

GIT_HOME=~/develop/ai-front/
DEST_PATH=~/prd/ai-front/

if [ ! -n "$1" ];
then
    echo -e "请输入项目名称，比如:"
    echo -e "./fe-deploy.sh xxx"
    exit
fi

if [ $1 = "ai-front" ];
then
    echo -e "---------进入项目--------"
    cd $GIT_HOME$1
else
    echo -e "Invalid Project Name!"
    exit
fi

# clean dist
echo -e "---------Clean Dist--------"
rm -rf ./build

echo -e "---------Git Pull--------"
git pull

echo -e "---------Yarn Install--------"
npm install

echo -e "---------Yarn Run Dist--------"
npm run build

if [ -d "./build" ];
then
    echo -e "---------clean Dest--------"
    rm -rf $DEST_PATH/build

    echo -e "---------copy Dest--------"
    cp -R ./build $DEST_PATH/$1/

    echo -e "---------Deploy Success--------"
else
    echo -e "---------Deploy Fail--------"
fi

